package com.ruoyi.familyUserManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.familyUserManagement.domain.DocFamilyUser;
import com.ruoyi.familyUserManagement.service.IDocFamilyUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家庭成员中间表管理Controller
 * 
 * @author ruoyi
 * @date 2025-08-14
 */
@RestController
@RequestMapping("/familyUserManagement/docFamilyUser")
public class DocFamilyUserController extends BaseController
{
    @Autowired
    private IDocFamilyUserService docFamilyUserService;

    /**
     * 查询家庭成员中间表管理列表
     */
    @PreAuthorize("@ss.hasPermi('familyUserManagement:docFamilyUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(DocFamilyUser docFamilyUser)
    {
        startPage();
        List<DocFamilyUser> list = docFamilyUserService.selectDocFamilyUserList(docFamilyUser);
        return getDataTable(list);
    }

    /**
     * 导出家庭成员中间表管理列表
     */
    @PreAuthorize("@ss.hasPermi('familyUserManagement:docFamilyUser:export')")
    @Log(title = "家庭成员中间表管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocFamilyUser docFamilyUser)
    {
        List<DocFamilyUser> list = docFamilyUserService.selectDocFamilyUserList(docFamilyUser);
        ExcelUtil<DocFamilyUser> util = new ExcelUtil<DocFamilyUser>(DocFamilyUser.class);
        util.exportExcel(response, list, "家庭成员中间表管理数据");
    }

    /**
     * 获取家庭成员中间表管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('familyUserManagement:docFamilyUser:query')")
    @GetMapping(value = "/{familyUserId}")
    public AjaxResult getInfo(@PathVariable("familyUserId") Long familyUserId)
    {
        return success(docFamilyUserService.selectDocFamilyUserByFamilyUserId(familyUserId));
    }

    /**
     * 新增家庭成员中间表管理
     */
    @PreAuthorize("@ss.hasPermi('familyUserManagement:docFamilyUser:add')")
    @Log(title = "家庭成员中间表管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocFamilyUser docFamilyUser)
    {
        return toAjax(docFamilyUserService.insertDocFamilyUser(docFamilyUser));
    }

    /**
     * 修改家庭成员中间表管理
     */
    @PreAuthorize("@ss.hasPermi('familyUserManagement:docFamilyUser:edit')")
    @Log(title = "家庭成员中间表管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocFamilyUser docFamilyUser)
    {
        return toAjax(docFamilyUserService.updateDocFamilyUser(docFamilyUser));
    }

    /**
     * 删除家庭成员中间表管理
     */
    @PreAuthorize("@ss.hasPermi('familyUserManagement:docFamilyUser:remove')")
    @Log(title = "家庭成员中间表管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{familyUserIds}")
    public AjaxResult remove(@PathVariable Long[] familyUserIds)
    {
        return toAjax(docFamilyUserService.deleteDocFamilyUserByFamilyUserIds(familyUserIds));
    }
}
